<?php
/**
 * @author: Đặng Văn Trường
 * @since: 22/07/2014
 * @todo : Model Van ban den
 */
class Module_Models_ReceiveDepartment extends Zend_Db_Table {	
	
	protected $_name="receivehandledepartment";
    protected $_primary_name;
    protected $_primary = "ReceiveHandleDepartmentID";
    protected $_detail = 'receivedetail';
    public function __construct()
    {
        parent::__construct();
        $this->_primary_name = $this->_primary;
    }
	
	
    public function selectRow($id){
        if($id){
            $query = $this->select()->from($this)->where($this->_primary_name.' = ?', $id);
            $rows = $this->getAdapter()->fetchRow($query);
            $rows['ReceivedDate'] = date('d/m/Y',strtotime($rows['ReceivedDate']));
            $rows['SendDate'] = date('d/m/Y',strtotime($rows['SendDate']));
        }else{
            $rows = array($this->_primary_name =>''
                            // ,'Code' =>''
                            // ,'Name' =>''
                            // ,'Orders' =>$orders['Orders']+1
                            // ,'Status' =>'1'
                            // ,'ListtypeID' =>''
                        );
        }
        return $rows;
    }

    public function deleteRows($listId){
        $aListID = explode(',', $listId);
        // Xoa file dinh kem
        // $modeFile = new System_Models_File();
        try {
            $where = $this->getAdapter()->quoteInto("$this->_primary_name IN (?)", $aListID);
            $result = $this->delete($where);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
        return $result;
    }
}
?>
